<template>
  <view>
    <image :src="url" @tap="previewImage(url)" mode="widthFix"></image>
    <view class="margin-top padding text-sm">
      <text>请先仔细阅读报名须知</text>
      <text class="text-red margin-left" v-if="countdown !== 0">{{ countdown }}s</text>
    </view>
    <view class="padding flex justify-around">
      <button class="cu-btn bg-green" :disabled="countdown !== 0" @tap="back">关闭</button>
    </view>

  </view>
</template>

<script lang="ts" setup>
import {usePreview} from "../../utils/usePreview";
import {computed, onBeforeMount, onBeforeUnmount, ref, watch} from "vue";
import {onLoad} from "@dcloudio/uni-app";

const url = ref(import.meta.env.VITE_BMXZ_URL)
const {previewImage} = usePreview()

const countdown = ref(1)

const NPage = ref<any>('')
onLoad((option:any)=>{
	NPage.value = option.n?decodeURIComponent(option.n):'';
	const interval = setInterval(() => {
    if (countdown.value === 0){
      clearInterval(interval)
      return
    }
    countdown.value--
  },1000)
})

interface ChooseProps {
  n?: any,
}

function back() {
  if(NPage.value){
    uni.redirectTo({
      url: NPage.value
    })
  }else{
    uni.navigateBack()
  }
  
}

</script>

<style scoped>
image{
  width: 100vw;
}
</style>
